﻿using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.DistributedEvents;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Modularity;

namespace Ordering.EntityFrameworkCore
{
    [DependsOn(
        typeof(OrderingDomainModule),
        typeof(AbpEntityFrameworkCoreModule)
    )]
    public class OrderingEntityFrameworkCoreModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAbpDbContext<OrderingDbContext>(options =>
            {
                options.AddDefaultRepositories(includeAllEntities: true);
            });

            Configure<AbpDistributedEventBusOptions>(options =>
            {
                options.Outboxes.Configure(config =>
                {
                    config.UseDbContext<OrderingDbContext>();
                });

                options.Inboxes.Configure(config =>
                {
                    config.UseDbContext<OrderingDbContext>();
                });
            });
        }
    }
}